
#import "FLMTenNineGoodsListCell.h"

#import "FLMTenNineFreeModel.h"
@implementation FLMTenNineGoodsListCell

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self drawUI];
    }
    return self;
}

- (void)drawUI {
    //商品主图ID
    _goods = [UIImageView new];
    [self addSubview:_goods];
    [_goods mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.width.mas_equalTo(self.frame.size.width);
        make.height.mas_equalTo(self.frame.size.height-70);
    }];
//    [_goods setImage:[UIImage imageNamed:@"1"]];

    //商品标题
    _titleLabel = [UILabel new];
    [self addSubview:_titleLabel];
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.frame.size.height-75);
        make.right.mas_equalTo(-5);
        make.left.mas_equalTo(5);
        make.height.mas_equalTo(40);
    }];
//    _titleLabel.text = @"美女滚滚床单美女滚滚床单美女滚滚床单美女滚滚床单美女滚滚床单美女滚滚床单";
    _titleLabel.numberOfLines = 0;
    _titleLabel.font = [UIFont systemFontOfSize:13];
    
    //商品价格
    _priceLabel = [UILabel new];
    [self addSubview:_priceLabel];
    [_priceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.frame.size.height-40);
        make.left.mas_equalTo(5);
        make.width.mas_equalTo(80);
        make.height.mas_equalTo(30);
    }];
//    _priceLabel.text = @"￥99.9";
    _priceLabel.font = [UIFont systemFontOfSize:13];
    _priceLabel.textColor = [UIColor redColor];
    
    //商品销量
    _saleLabel = [UILabel new];
    [self addSubview:_saleLabel];
    [_saleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.frame.size.height-20);
        make.left.mas_equalTo(5);
        make.width.mas_equalTo(100);
        make.height.mas_equalTo(20);
    }];
//    _saleLabel.text = @"60346件";
    _saleLabel.textColor = gray;
    _saleLabel.font = [UIFont systemFontOfSize:13];
    
    //商品返利
    _rebateLabel = [UILabel new];
    [self addSubview:_rebateLabel];
    [_rebateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.frame.size.height-20);
        make.right.mas_equalTo(5);
        make.width.mas_equalTo(70);
        make.height.mas_equalTo(20);
    }];
    _rebateLabel.text = @"返利:5%";
    _rebateLabel.font = [UIFont systemFontOfSize:13];
    
    /************/
    _limitedTimePic = [UIImageView new];
    [self addSubview:_limitedTimePic];
    [_limitedTimePic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(5);
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(30);
    }];
    [_limitedTimePic setImage:[UIImage imageNamed:@"limitedTimePic"]];
    
    _todayNewPic = [UIImageView new];
    [_goods addSubview:_todayNewPic];
    [_todayNewPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(40);
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(50);
        make.height.mas_equalTo(30);
    }];
    [_todayNewPic setImage:[UIImage imageNamed:@"todayNewPic"]];
    
    _couponPic = [UIImageView new];
    [self addSubview:_couponPic];
    [_couponPic mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-80);
        make.right.mas_equalTo(-10);
        make.width.mas_equalTo(30);
        make.height.mas_equalTo(30);
    }];
    [_couponPic setImage:[UIImage imageNamed:@"couponPic"]];
}

- (void)isHiddenLimitedTimePic {
    //if (存在数据) {
       // _limitedTimePic.hidden = NO;
    //} else {
      //  _limitedTimePic.hidden = YES;
    //}
}

- (void)isHiddenTodayNewPic {
    _todayNewPic.hidden = NO;
}

- (void)isHiddenCouponPic {
    _couponPic.hidden = NO;
}

- (void)configueCellWithModel:(FLMTenNineGoodslistModel *)nineGoodModels {
    _todayNewPic.hidden = NO;
    _limitedTimePic.hidden = NO;
    // 商品主图
    [_goods sd_setImageWithURL:[NSURL URLWithString:nineGoodModels.pict_url] placeholderImage:[UIImage imageNamed:@"placeholder"]];
    // 商品标题
    _titleLabel.text = nineGoodModels.title;
    // 商品价格
    _priceLabel.text = [NSString stringWithFormat:@"￥%@",nineGoodModels.zk_final_price];
    // 商品销量
    _saleLabel.text = [NSString stringWithFormat:@" %@",nineGoodModels.volume];
}
@end
